package com.akk.module.user.service;

import com.akk.module.user.entity.UserAgent;
import com.akk.module.user.entity.UserAgentExample;
import com.akk.module.user.mapper.UserAgentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAgentService {
    @Autowired
    UserAgentMapper userAgentMapper;
    @Autowired
    UserAgentExample userAgentExample;

    public UserAgent findByAgentId(String agentId) {
        UserAgent userAgent = userAgentMapper.selectByPrimaryKey(agentId);
        return userAgent == null? new UserAgent():userAgent;
    }

    public List<UserAgent> findByAppId(String appId) {
        userAgentExample.clear();
        userAgentExample.createCriteria().andAppIdEqualTo(appId);
        return userAgentMapper.selectByExample(userAgentExample);
    }

    public List<UserAgent> findByPhone(String phone) {
        userAgentExample.clear();
        userAgentExample.createCriteria().andPhoneEqualTo(phone);
        return userAgentMapper.selectByExample(userAgentExample);
    }
}
